#include <47func.h>
int main(int argc, char *argv[])
{
    // ./0_client_udp 192.168.118.128 1234
    ARGS_CHECK(argc,3);
    int sockfd = socket(AF_INET,SOCK_DGRAM,0);//SOCK_DGRAM 意味着传输层是udp
    // 设置服务端地址信息
    struct sockaddr_in serverAddr;
    serverAddr.sin_family = AF_INET;
    serverAddr.sin_addr.s_addr = inet_addr(argv[1]);
    serverAddr.sin_port = htons(atoi(argv[2]));
    // 根据服务端地址sendto
    ssize_t sret = sendto(sockfd,"hello",5,0,(struct sockaddr *)&serverAddr,sizeof(serverAddr));
    ERROR_CHECK(sret,-1,"sendto");
    char buf[1024] = {0};
    sleep(5);
    sret = recvfrom(sockfd,buf,sizeof(buf),0,NULL,NULL);
    ERROR_CHECK(sret,-1,"recvfrom");
    printf("buf = %s\n", buf);
    close(sockfd);
    return 0;
}

